<!DOCTYPE html>
<html lang="zh-cn">
   <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>{$CONF['mallTitle']}后台管理中心</title>
      <link href="__PUBLIC__/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
      <link href="__ROOT__/Apps/Admin/View/css/AdminLTE.css" rel="stylesheet" type="text/css" />
      <!--[if lt IE 9]>
      <script src="__PUBLIC__/js/html5shiv.min.js"></script>
      <script src="__PUBLIC__/js/respond.min.js"></script>
      <![endif]-->
      <script src="__PUBLIC__/js/jquery.min.js"></script>
      <script src="__PUBLIC__/plugins/bootstrap/js/bootstrap.min.js"></script>
      <script src="__PUBLIC__/js/common.js"></script>
      <script src="__PUBLIC__/plugins/plugins/plugins.js"></script>
      <script src="__PUBLIC__/plugins/plugins/formValidator/formValidator-4.1.3.js"></script>
   </head>
   <script>
   function changeRecom(id,v){
	   Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
	   $.post('{:U("Admin/Shops/changeRecom")}',{id:id,isRecom:v},function(data,textStatus){
				var json = MXC.toJson(data);
				if(json.status=='1'){
					Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){
					    location.reload();
					}});
				}else{
					
					Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});
				
				}
	   });
   }
   function stop(id){
	   Plugins.confirm({title:'信息提示',content:'您确定要停止该商家吗?',okText:'确定',cancelText:'取消',okFun:function(){
		   Plugins.closeWindow();
		   Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
		   $.post("{:U('Admin/Shops/stop')}",{id:id},function(data,textStatus){
					var json = MXC.toJson(data);
					if(json.status=='1'){
						Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){
							location.reload();
						}});
					}else{
						Plugins.closeWindow();
						parent.showMsg({msg:'操作失败!',status:'danger'});
					}
				});
	      }});
   }
   function closeShop(id){
	   Plugins.confirm({title:'信息提示',content:'您确定要关闭该商家吗?',okText:'确定',cancelText:'取消',okFun:function(){
		   Plugins.closeWindow();
		   Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
		   $.post("{:U('Admin/Shops/closeShop')}",{id:id},function(data,textStatus){
					var json = MXC.toJson(data);
					if(json.status=='1'){
						Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){
							location.reload();
						}});
					}else{
						Plugins.closeWindow();
						parent.showMsg({msg:'操作失败!',status:'danger'});
					}
				});
	      }});
   }
   function getAreaList(objId,parentId,t,id){
	   var params = {};
	   params.parentId = parentId;
	   $('#'+objId).empty();
	   if(t<1){
		   $('#areaId3').empty();
		   $('#areaId3').html('<option value="">请选择</option>');
	   }
	   var html = [];
	   $.post("{:U('Admin/Areas/queryByList')}",params,function(data,textStatus){
		    html.push('<option value="">请选择</option>');
			var json = MXC.toJson(data);
			if(json.status=='1' && json.list.length>0){
				var opts = null;
				for(var i=0;i<json.list.length;i++){
					opts = json.list[i];
					html.push('<option value="'+opts.areaId+'" '+((id==opts.areaId)?'selected':'')+'>'+opts.areaName+'</option>');
				}
			}
			$('#'+objId).html(html.join(''));
	   });
   }
   $(document).ready(function(){
	    <notempty name='areaId1'>
		   getAreaList("areaId2",'{$areaId1}',0,'{$areaId2}');
		</notempty>
   });
   
   </script>
   <body class='mxc-page'>
     <form method='post' action="{:U('Admin/Shops/index')}">
       <div class='mxc-tbar'> 
    地区：<select id='areaId1' name='areaId1' onchange='javascript:getAreaList("areaId2",this.value,0)'>
               <option value=''>请选择</option>
               <volist name="areaList" id="vo">
               <option value='{$vo['areaId']}' <if condition="$areaId1 == $vo['areaId'] ">selected</if>>{$vo['areaName']}</option>
               </volist>
             </select>
             <select id='areaId2' name='areaId2'>
               <option value=''>请选择</option>
             </select>    
       店铺名称：<input type='text' id='shopName' name='shopName' class='form-control mxc-ipt-10' value='{$shopName}'/> 
  <button type="submit" class="btn btn-primary glyphicon glyphicon-search">查询</button> 
  &nbsp;&nbsp;&nbsp;&nbsp;
  <a  href="{:u('Shops/adminCreateShop')}" class="btn btn-primary glyphicon  ">开店</a> 
  <!--<php>if(in_array('dplb_01',$MXC_STAFF['grant'])){</php>
  <a class="btn btn-success glyphicon glyphicon-plus" href="{:U('Admin/Shops/toEdit')}" style='float:right'>新增</a>
  <php>}</php>   -->  
       </div>
       </form>
       <div class='mxc-body'>
        <table class="table table-hover table-striped table-bordered mxc-list">
           <thead>
             <tr>
               <th width='30'>序号</th>
               <th width='20'>店铺ID</th>
               <th width='80'>店铺名称</th>
               <th width='80'>店主</th>
 
               <th width='80'>登录用户</th>
               <th width='80'>店铺类型</th>
               <th width='60'>店铺状态</th>
               <th width='60'>推荐</th>
               <th width='120'>操作</th>
             </tr>
           </thead>
           <tbody>
            <volist name="Page['root']" id="vo" key='i'>
             <tr>
               <td>{$i}{$vo['isRecom']}</td>
               <td>{$vo['shopId']}</td>
               <td>{$vo['shopName']}</td>
               <td>{$vo['fullName']}&nbsp;</td>
               <td>用户ID:{$vo['userId']}用户名:{$vo['userName']}手机号:{$vo['userPhone']}</td>
                
               <td>
               <if condition="$vo['userType'] ==1 "><span class='label label-success'>企业</span></if>
               <if condition="$vo['userType'] ==2 "><span class='label label-warning'>个人</span></if>&nbsp;</td>
               <td>
               <if condition="$vo['shopStatus'] eq -2"><span class='label label-danger mxc-label'>已停止</span> </if>
               <if condition="$vo['shopStatus'] eq -1"><span class='label label-danger mxc-label'>拒绝</span>  </if>
               <if condition="$vo['shopStatus'] eq 0"><span class='label label-primary mxc-label'>未审核</span> </if>
               <if condition="$vo['shopStatus'] eq 1"><span class='label label-success mxc-label'>已审核</span>  </if>&nbsp;
               </td>
               <td>
               <if condition="$vo['isRecom'] ==1 "><span class="label label-success">推荐</span></if>
               </td>
               <td>
               <if condition="$vo['isRecom'] ==1 ">
               <button type="button" class="btn btn-primary glyphicon" onclick="javascript:changeRecom({$vo['shopId']},0)">取消推荐</button>
               <else />
               <button type="button" class="btn btn-primary glyphicon" onclick="javascript:changeRecom({$vo['shopId']},1)">设置推荐</button>
               </if>
               <php>if(in_array('dplb_02',$MXC_STAFF['grant'])){</php>
               <a class="btn btn-default glyphicon glyphicon-pencil" href="{:U('Admin/Shops/toEdit',array('id'=>$vo['shopId'],'src'=>'index'))}">修改</a>&nbsp;
               <php>}</php>
               <php>if(in_array('dplb_03',$MXC_STAFF['grant'])){</php>
               <button type="button" class="btn btn-default glyphicon glyphicon-trash" onclick="javascript:stop({$vo['shopId']})">停止</button>
               <php>}</php>
               <php>if(in_array('dplb_03',$MXC_STAFF['grant'])){</php>
               <button type="button" class="btn btn-default glyphicon" onclick="javascript:closeShop({$vo['shopId']})">关闭店铺</button>
               <php>}</php>
               </td>
             </tr>
             </volist>
             <tr>
                <td colspan='11' align='center'>{$Page['pager']}</td>
             </tr>
           </tbody>
        </table>
       </div>
   </body>
</html>
